<?php
/**
 * Wysiwyg
 * This plugin can create WYSIWYG areas with NicEdit editor
 * Home of NicEdit: http://nicedit.com/
 * WARNING: It`s not tested for creating more than ONE textarea per page ;)
 * @package
 * @author kubicek
 * @copyright Copyright (c) 2010
 * @version $Id$
 * @access public
 */
class Wysiwyg extends Plugin
{
	public $plugin_name = "Wysiwyg"; //name of plugin
	public $plugin_short_desc = "Wysiwyg editor NicEdit"; //short description of plugin
	public $plugin_long_desc = "Adds WYSIWYG capability to targeted textarea"; //longer description - what does plugin do
	public $version = "1.0"; //version of plugin
	public $has_sidebar = false; //does this plugin have sidebar -> function generate_sidebar()
	public $has_footer = false; //does this plugin have footer -> function generate_footer()


	function __construct()
	{
	}

	public function create_wysiwyg($area = 'wysiwyg_area')
	{
		global $core,$theme;

		//javascript for wysiwyg editor
		$theme->add_to_head($theme->include_js($this->get_plugin_path().'nicEdit.js'));
		$theme->add_to_head('<script type="text/javascript">
	bkLib.onDomLoaded(function() { new nicEditor({iconsPath : \''.$this->get_plugin_path().'nicEditorIcons.gif\',fullPanel : true}).panelInstance(\''.$area.'\'); });
</script>');
	}

	/**
	 * Wysiwyg::admin_settings()
	 * Example of usafe
	 * @return
	 */
	public function admin_settings()
	{
		global $core;

		if($core->is_plugin('highlight')) //lets check for hilit plugin
		{
			$hl = $core->load_plugin('highlight');
		}

		$this->create_wysiwyg('wysiwyg'); //create wysiwyg area

		echo '<p>Usage in Yaps!: </p>';
		$text = nl2br('$plugin = $core->load_plugin(\'wysiwyg\');
$plugin->create_wysiwyg(\'id_of_your_textarea\');');

		echo (isset($hl)) ? $hl->text($text) : $text;

		echo '<p>And result:</p>
					<textarea id="wysiwyg" rows="5" cols="60"></textarea>';
	}
}


?>